package Extended;

import java.awt.geom.*;


public class GetShape
{
	public static GeneralPath GetTriangle(int X, int Y, int Size, int Rotate)
	{
		GeneralPath gp = new GeneralPath();

		switch(Rotate)
		{
			case 0:
			{
				gp.append(new Line2D.Double(X - Size, Y + (Size / 2), X, Y - (Size / 2)), true);
				gp.lineTo(X + Size, Y + (Size / 2));
				gp.lineTo(X - Size, Y + (Size / 2));

				break;
			}
			case 1:
			{
				gp.append(new Line2D.Double(X + (Size / 2), Y + Size, X - Size, Y - (Size / 2)), true);
				gp.lineTo(X + (Size / 2), Y - (Size / 2));
				gp.lineTo(X + (Size / 2), Y + Size);

				break;
			}
			case 2:
			{
				gp.append(new Line2D.Double(X - (Size / 2), Y - Size, X - (Size / 2), Y + Size), true);
				gp.lineTo(X + (Size / 2), Y);
				gp.lineTo(X - (Size / 2), Y - Size);

				break;
			}
			case 3:
			{
				gp.append(new Line2D.Double(X - Size, Y + (Size / 2), X + (Size / 2), Y - Size), true);
				gp.lineTo(X + (Size / 2), Y + (Size / 2));
				gp.lineTo(X - Size, Y + (Size / 2));

				break;
			}
			case 4:
			{
				gp.append(new Line2D.Double(X, Y + (Size / 2), X - Size, Y - (Size / 2)), true);
				gp.lineTo(X + Size, Y - (Size / 2));
				gp.lineTo(X, Y + (Size / 2));

				break;
			}
			case 5:
			{
				gp.append(new Line2D.Double(X - (Size / 2), Y + (Size / 2), X - (Size / 2), Y - Size), true);
				gp.lineTo(X + Size, Y + (Size / 2));
				gp.lineTo(X - (Size / 2), Y + (Size / 2));

				break;
			}
			case 6:
			{
				gp.append(new Line2D.Double(X - (Size / 2), Y, X + (Size / 2), Y - Size), true);
				gp.lineTo(X + (Size / 2), Y + Size);
				gp.lineTo(X - (Size / 2), Y);

				break;
			}
			case 7:
			{
				gp.append(new Line2D.Double(X - (Size / 2), Y + Size, X - (Size / 2), Y - (Size / 2)), true);
				gp.lineTo(X + Size, Y - (Size / 2));
				gp.lineTo(X - (Size / 2), Y + Size);

				break;
			}
		}

		return gp;
	}

	public static GeneralPath GetSquare(int X, int Y, int Size, int Rotate)
	{
		GeneralPath gp = new GeneralPath();

		switch(Rotate)
		{
			case 0:
			{
				gp.append(new Line2D.Double(X - (Size / 1.5), Y + (Size / 1.5), X - (Size / 1.5), Y - (Size / 1.5)), true);
				gp.lineTo(X + (Size / 1.5), Y - (Size / 1.5));
				gp.lineTo(X + (Size / 1.5), Y + (Size / 1.5));
				gp.lineTo(X - (Size / 1.5), Y + (Size / 1.5));

				break;
			}
			case 1:
			{
				gp.append(new Line2D.Double(X - Size, Y, X, Y - Size), true);
				gp.lineTo(X + Size, Y);
				gp.lineTo(X, Y + Size);
				gp.lineTo(X - Size, Y);

				break;
			}
		}

		gp.closePath();

		return gp;
	}

	public static GeneralPath GetDiamond(int X, int Y, int Size, int Rotate)
	{
		GeneralPath gp = new GeneralPath();

		switch(Rotate)
		{
			case 0:
			{
				gp.append(new Line2D.Double(X - (Size / 2), Y + (Size * 1.5), X - (Size / 2), Y - (Size / 2)), true);
				gp.lineTo(X + (Size / 2), Y - (Size * 1.5));
				gp.lineTo(X + (Size / 2), Y + (Size / 2));
				gp.lineTo(X - (Size / 2), Y + (Size * 1.5));

				break;
			}
			case 1:
			{
				gp.append(new Line2D.Double(X - (Size * 1.5), Y + (Size / 2), X, Y - Size), true);
				gp.lineTo(X + (Size * 1.5), Y - Size);
				gp.lineTo(X, Y + (Size / 2));
				gp.lineTo(X - (Size * 1.5), Y + (Size / 2));

				break;
			}
			case 2:
			{
				gp.append(new Line2D.Double(X - (Size / 2), Y + (Size / 2), X - (Size * 1.5), Y - (Size / 2)), true);
				gp.lineTo(X + (Size / 2), Y - (Size / 2));
				gp.lineTo(X + (Size * 1.5), Y + (Size / 2));
				gp.lineTo(X - (Size / 2), Y + Size / 2);

				break;
			}
			case 3:
			{
				gp.append(new Line2D.Double(X - Size, Y, X - Size, Y - (Size * 1.5)), true);
				gp.lineTo(X + (Size / 2), Y);
				gp.lineTo(X + (Size / 2), Y + (Size * 1.5));
				gp.lineTo(X - Size, Y);

				break;
			}
			case 10:
			{
				gp.append(new Line2D.Double(X - (Size / 2), Y - (Size * 1.5), X - (Size / 2), Y + (Size / 2)), true);
				gp.lineTo(X + (Size / 2), Y + (Size * 1.5));
				gp.lineTo(X + (Size / 2), Y - (Size / 2));
				gp.lineTo(X - (Size / 2), Y - (Size * 1.5));

				break;
			}
			case 11:
			{
				gp.append(new Line2D.Double(X - (Size * 1.5), Y - Size, X, Y + (Size / 2)), true);
				gp.lineTo(X + (Size * 1.5), Y + (Size / 2));
				gp.lineTo(X, Y - Size);
				gp.lineTo(X - (Size * 1.5), Y - Size);

				break;
			}
			case 12:
			{
				gp.append(new Line2D.Double(X - (Size / 2), Y - (Size / 2), X - (Size * 1.5), Y + (Size / 2)), true);
				gp.lineTo(X + (Size / 2), Y + (Size / 2));
				gp.lineTo(X + (Size * 1.5), Y - (Size / 2));
				gp.lineTo(X - (Size / 2), Y - Size / 2);

				break;
			}
			case 13:
			{
				gp.append(new Line2D.Double(X - (Size / 2), Y, X - (Size / 2), Y + (Size * 1.5)), true);
				gp.lineTo(X + Size, Y);
				gp.lineTo(X + Size, Y - (Size * 1.5));
				gp.lineTo(X - (Size / 2), Y);

				break;
			}
		}

		gp.closePath();

		return gp;
	}


	public static boolean OnTriangle(int CheckX, int CheckY, int X, int Y, int Size, int Rotate)
	{
		int i;
		int c;

		switch(Rotate)
		{
			case 0:
			{
				for(i = X - Size, c = 0; i <= X; i ++, c ++)
					if(CheckX == i && CheckY <= Y + (Size / 2) && CheckY >= Y + (Size / 2) - c)
						return true;

				for(i = X, c = 0; i <= X + Size; i ++, c ++)
					if(CheckX == i && CheckY <= Y + (Size / 2) && CheckY >= Y - (Size / 2) + c)
						return true;

				break;
			}
			case 1:
				for(i = Y - (Size / 2), c = 0; i <= Y + Size; i ++, c ++)
					if(CheckY == i && CheckX <= X + (Size / 2) && CheckX >= (X - Size) + c)
						return true;
				break;
			case 2:
			{
				for(i = Y - Size, c = 0; i <= Y; i ++, c ++)
					if(CheckY == i && CheckX >= X - (Size / 2) && CheckX <= X - (Size / 2) + c)
						return true;

				for(i = Y, c = 0; i <= Y + Size; i ++, c ++)
					if(CheckY == i && CheckX >= X - (Size / 2) && CheckX <= X + (Size / 2) - c)
						return true;

				break;
			}
			case 3:
				for(i = Y - Size, c = 0; i <= Y + (Size / 2); i ++, c ++)
					if(CheckY == i && CheckX <= X + (Size / 2) && CheckX >= X + (Size / 2) - c)
						return true;
				break;
			case 4:
			{
				for(i = X - Size, c = 0; i <= X; i ++, c ++)
					if(CheckX == i && CheckY >= Y - (Size / 2) && CheckY <= Y - (Size / 2) + c)
						return true;

				for(i = X, c = 0; i <= X + Size; i ++, c ++)
					if(CheckX == i && CheckY >= Y - (Size / 2) && CheckY <= Y + (Size / 2) - c)
						return true;

				break;
			}
			case 5:
				for(i = Y - Size, c = 0; i <= Y + (Size / 2); i ++, c ++)
					if(CheckY == i && CheckX >= X - (Size / 2) && CheckX <= X - (Size / 2) + c)
						return true;
				break;
			case 6:
			{
				for(i = Y - Size, c = 0; i <= Y; i ++, c ++)
					if(CheckY == i && CheckX <= X + (Size / 2) && CheckX >= X + (Size / 2) - c)
						return true;

				for(i = Y, c = 0; i <= Y + Size; i ++, c ++)
					if(CheckY == i && CheckX <= X + (Size / 2) && CheckX >= X - (Size / 2) + c)
						return true;

				break;
			}
			case 7:
				for(i = Y - (Size / 2), c = 0; i <= Y + Size; i ++, c ++)
					if(CheckY == i && CheckX >= X - (Size / 2) && CheckX <= (X + Size) - c)
						return true;
				break;
		}

		return false;
	}

	public static boolean OnSquare(int CheckX, int CheckY, int X, int Y, int Size, int Rotate)
	{
		int i;
		int c;

		switch(Rotate)
		{
			case 0:
				if(CheckX > X - (Size / 1.5) && CheckX < X + (Size / 1.5) && CheckY > Y - (Size / 1.5) && CheckY < Y + (Size / 1.5))
					return true;
				break;
			case 1:
			{
				for(i = Y - Size, c = 0; i <= Y; i ++, c ++)
					if(CheckY == i && CheckX >= X - c && CheckX <= X + c)
						return true;

				for(i = Y, c = 0; i <= Y + Size; i ++, c ++)
					if(CheckY == i && CheckX >= X - Size + c && CheckX <= X + Size - c)
						return true;

				break;
			}
		}

		return false;
	}

	public static boolean OnDiamond(int CheckX, int CheckY, int X, int Y, int Size, int Rotate)
	{
		int i;
		int c;

		switch(Rotate)
		{
			case 0:
				for(i = X - (Size / 2), c = 0; i <= X + (Size / 2); i ++, c ++)
					if(CheckX == i && CheckY >= Y - (Size / 2) - c && CheckY <= Y + (Size * 1.5) - c)
						return true;
				break;
			case 1:
				for(i = Y - Size, c = 0; i <= Y + (Size / 2); i ++, c ++)
					if(CheckY == i && CheckX >= X - c && CheckX <= X + (Size * 1.5) - c)
						return true;
				break;
			case 2:
				for(i = Y - (Size / 2), c = 0; i <= Y + (Size / 2); i ++, c ++)
					if(CheckY == i && CheckX >= X - (Size * 1.5) - c && CheckX <= X + (Size / 2) + c)
						return true;
				break;
			case 3:
				for(i = X - Size, c = 0; i <= X + (Size / 2); i ++, c ++)
					if(CheckX == i && CheckY >= Y - (Size * 1.5) + c && CheckY <= Y + c)
						return true;
				break;
			case 10:
				for(i = X - (Size / 2), c = 0; i <= X + (Size / 2); i ++, c ++)
					if(CheckX == i && CheckY >= Y - (Size * 1.5) + c && CheckY <= Y + (Size / 2) + c)
						return true;
				break;
			case 11:
				for(i = Y - Size, c = 0; i <= Y + (Size / 2); i ++, c ++)
					if(CheckY == i && CheckX >= X - (Size * 1.5) + c && CheckX <= X + c)
						return true;
				break;
			case 12:
				for(i = Y - (Size / 2), c = 0; i <= Y + (Size / 2); i ++, c ++)
					if(CheckY == i && CheckX >= X - (Size / 2) - c && CheckX <= X + (Size * 1.5) - c)
						return true;
				break;
			case 13:
				for(i = X - (Size / 2), c = 0; i <= X + Size; i ++, c ++)
					if(CheckX == i && CheckY >= Y - c && CheckY <= Y + (Size * 1.5) - c)
						return true;
				break;
		}

		return false;
	}
}
